<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>工单列表</title> 
<link href="${ctx}/statics/css/base.css" rel="stylesheet">
<link rel="stylesheet" href="${ctx}/statics/css/uimaker/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/statics/css/uimaker/icon.css">
<link rel="stylesheet" href="${ctx}/statics/css/providers1.css">
</head> 
<body>
    <div class="container">
       <table id="dg" style="width:100%;height:529px" title="" 
       		data-options="rownumbers:true,
       		pagination:true,
       		toolbar:'#tb',
            singleSelect:false,
            autoRowHeight:false,
            pagination:true,
            fitColumns:true,
            striped:true,
            checkOnSelect:false,
            selectOnCheck:false,
            collapsible:true,
       		url:'${ctx}/order/listpage',
       		method:'get'">
            <thead>
                <tr>
                	<th data-options="field:'sellerId',width:60,align:'center',formatter:optFormatter">操作</th>
					<th data-options="field:'id',width:80">订单号</th>
					<th data-options="field:'sellerName',width:100">商家名称</th>
					<th data-options="field:'buyerName',width:80">车主</th>
					<th data-options="field:'buyerMobile',width:80,align:'right'">车主电话</th>
					<th data-options="field:'buyerCarType',width:80">车型</th>
					<th data-options="field:'buyerProduct',width:120">安装产品</th>
					<th data-options="field:'price',width:60,align:'right',formatter:priceFormatter">价格</th>
				</tr>
            </thead>
        </table>
      <div id="tb" style="padding:0 30px;">
        <div class="conditions">
            <span class="con-span">订单号: </span><input id="query_orderId" class="easyui-textbox" type="text" name="query_orderId" style="width:166px;height:35px;line-height:35px;"></input>
            <span class="con-span">车主电话: </span><input class="easyui-textbox" id="query_mobile" type="text" name="query_mobile" style="width:166px;height:35px;line-height:35px;"></input>
            <a class="easyui-linkbutton search-btn" iconCls="icon-search" data-options="selected:true">查询</a>
            <a class="easyui-linkbutton" iconCls="icon-reload">重置</a>
            <a class="easyui-linkbutton more" iconCls="icon-more">更多</a>
        </div>
        <div class="conditions hide">
            <span class="con-span">商家: </span>
            	<select class="easyui-combobox" id="query_sellerId" name="query_sellerId" style="height:35px;width:166px;">
					<option value="">请选择</option>
					<option value="1">3M旗舰店</option>
					<option value="2">龙膜旗舰店</option>
				</select>
            <span class="con-span">创建时间: </span><input id="query_beginTime" class="easyui-datebox" type="text" name="query_beginTime" style="width:166px;height:35px;line-height:35px;"></input>-&nbsp;&nbsp;<input class="easyui-datebox" id="query_endTime" type="text" name="query_endTime" style="width:166px;height:35px;line-height:35px;"></input>
        </div>
        <div class="opt-buttons">
            <a href="${ctx}/order/add" class="easyui-linkbutton" data-options="selected:true">新增</a>
            <a href="${ctx}/order/toupladpage" class="easyui-linkbutton">Excel导入</a>
            <a href="${ctx}/order/excelout" class="easyui-linkbutton">Excel导出</a>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="${ctx}/statics/js/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/statics/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${ctx}/statics/easyui/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        var priceFormatter = function(value, row, index) {
        	// 四舍五入
        	var num = new Number(value);
        	num = num.toFixed(2);
        	var html = "￥ <span style='color:#f40'>" + num + "</span>";
        	return html;
        }
        
        function confirmDelete() {
        	var id = arguments[0];
        	if (confirm('确定删除？')) {
        		var url = '${ctx}/order/delete/' + id;
        		$.getJSON(url, {}, function(data) {
        			if (data.flag == true) {
        				alert(data.message);
        				$('#dg').datagrid();
        			}
        		});
        	}
        }
        
        var optFormatter = function(value, row, index) {
        	return "<a href='javascript:confirmDelete(" + row.id + ")'>删除</a> <a href='${ctx}/order/edit/" + row.id + "'>编辑</a> <a href='${ctx}/order/view/" + row.id + "'>查看</a>";
        }
        
        $(function(){
        	$('.search-btn').on('click', function() {
        		$('#dg').datagrid('load',{
					query_orderId: $("#query_orderId").textbox('getValue'),
					query_mobile: $("#query_mobile").textbox('getValue'),
					query_sellerId:$("#query_sellerId").combobox('getValue'),
					query_beginTime:$("#query_beginTime").textbox('getValue'),
					query_endTime:$("#query_endTime").textbox('getValue')
				});
        	});
        
        
            $('#dg').datagrid();
        });    

        $(".more").click(function(){
            $(this).closest(".conditions").siblings().toggleClass("hide");
        });
        
        $(function() {
			<#if errorMessage??>
				alert("${errorMessage!}");
			</#if>
			<#if successMessage??>
				alert("${successMessage!}");
			</#if>
		});
    </script>
</body> 
</html>
